import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { userType } from '../types/user'
export const setUserInfo = defineStore(
  'userInfo',
  () => {
    // 用户信息
    const user = ref<userType>()

    // 设置用户登录后使用
    const setUser = (u: userType) => {
      user.value = u
    }

    // 清空用户信息
    const delUser = () => {
      user.value = undefined
    }

    return { user, setUser, delUser }
  },
  {
    // 设置持久化存储
    persist: true
  }
)
